package com.example.administrator.szb.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.szb.R;
import com.example.administrator.szb.activity.base.BasePresenter;
import com.example.administrator.szb.activity.base.MVPBaseActivity;
import com.example.administrator.szb.util.FinishActivity;

public class Success2Activity extends MVPBaseActivity {
    private Button success_button_fhsy;
    private TextView tips;
    private TextView title;
    private boolean isGoHome = true;
    private String titles;
    private String content;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.success);
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected void initView() {
        title = findViewById(R.id.bar_title);
        tips = findViewById(R.id.success_text);
        success_button_fhsy = findViewById(R.id.success_button_fhsy);
    }

    @Override
    protected void initEvent() {
        success_button_fhsy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goHome();

            }
        });
    }

    @Override
    protected void initData() {
        isGoHome = getIntent().getBooleanExtra("is_go_home",true);
        titles = getIntent().getStringExtra("titles");
        content = getIntent().getStringExtra("content");
        String btn_text = getIntent().getStringExtra("btn_text");
        title.setText(titles);
        if (!TextUtils.isEmpty(content)){
            tips.setText(content);
        }
        if (!TextUtils.isEmpty(btn_text)){
            success_button_fhsy.setText(btn_text);
        }


    }

    @Override
    public void onFinish(View view) {
        goHome();
    }

    @Override
    public void onBackPressed() {
        goHome();
    }

    public void goHome(){
        if (isGoHome){
            FinishActivity.finish();
            Intent intent = new Intent(this,HomeActivity.class);
            startActivity(intent);
            finish();
        }else {
            finish();
        }
    }
}
